<?php
class OffersColumnsController extends AppController {

	var $name = 'OffersColumns';

	function index() {
		$this->OffersColumn->recursive = 0;
		$this->paginate['limit'] = 300;
		$this->set('offersColumns', $this->paginate());
	}



	function edit($id = null,$typ=null) {
		if (!empty($this->data)) {
			if ($this->OffersColumn->save($this->data)) {
				$this->Session->setFlash(__('Dane zostały zapisane pomylnie', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The transakcja could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data) && !is_null($id) && !is_null($typ)) {		
			$column = $this->OffersColumn->field($typ, array('OffersColumn.id'=>$id));
			$this->OffersColumn->id = $id;
			$onoff = array('OffersColumn'=>array('id'=>$id,$typ=>!$column));
			if ($this->OffersColumn->save($onoff)) {
				$this->Session->setFlash(__('The offers column has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The offers column could not be saved. Please, try again.', true));
				$this->redirect(array('action' => 'index'));
			}
		}
		
		if (empty($this->data) && !is_null($id)) {
			$this->data = $this->OffersColumn->read(null, $id);
		}

	}

}
